package com.cloudcc.mobile.presenter;

import com.cloudcc.cloudframe.bus.EventEngine;
import com.cloudcc.cloudframe.bus.EventList.PushRegisterEvent;
import com.cloudcc.cloudframe.model.param.PushRegisterParam;
import com.cloudcc.cloudframe.model.push.PushBindModel;
import com.cloudcc.cloudframe.util.StringUtils;
import com.cloudcc.mobile.dao.PushEngine;
import com.cloudcc.mobile.dao.impl.PushEngineImpl;
import com.cloudcc.mobile.manager.CloudCCPushManager;
import com.cloudcc.mobile.manager.UserManager;

public class PushPresenter extends BasePresenter {

	private PushEngine engine = new PushEngineImpl();

	/** 
	* bind 注册 push
	*/ 
	public void registerBind() {
		PushRegisterEvent event = new PushRegisterEvent();

		PushBindModel bind = CloudCCPushManager.getInstance().getPushBind();

		if (StringUtils.isBlank(bind.channelId)
				|| StringUtils.isBlank(bind.userId)
				|| StringUtils.isBlank(bind.appid)) {
			event.setOk(false);
			event.setMessage("bind为空");
			EventEngine.post(event);
			return;
		}
		PushRegisterParam param = new PushRegisterParam();
		param.ccuserId = UserManager.getManager().getUser().userId;
		param.channelId = bind.channelId;
		param.deviceUserId = bind.userId;
		param.deviceType = "3";
		param.orgId = UserManager.getManager().getUser().orgId;
		param.groupTags = UserManager.getManager().getUser().orgId;

		engine.registerPush(param, event);

	}

}
